<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<title>医师信息</title>
<%@ include file="/commons/static.jsp"%>
<link href="${ctx}/home/date/date.css" rel="stylesheet">
<script type="text/javascript" src="${ctx}/dep/date/date.js"></script>

</head>
<body>
	<div class="wrapper">
		<!-- 面包屑导航 -->
		<div class="page-breadcrumbs">
			<ul class="breadcrumb">
				<li><i class="fa fa-home"></i> <a href="index.html">首页</a></li>
				<li class="active"><a href="doctor.html">医师信息管理</a></li>
				<li class="active">医师信息服务</li>
			</ul>
		</div>
		<!-- /面包屑导航-->
		<div class="page-body">
			<div class="row">
				<div class="col-xs-12 col-md-12">
					<div class="widget">
						<div class="widget-body">
							<div class="table-toolbar">
								<a href="" class="btn btn-darkorange col-padd" id="deleteBatch">
									<i class="fa fa-minus"></i>批量删除
								</a> <a href="${ctx }/doctor/add" class="btn btn-blue col-padd">
									<i class="fa fa-plus"></i>新增医师信息
								</a> <a href="javascript:void(0)" class="btn btn-azure col-padd"
									onclick="check()"> <i class="fa fa-check-square-o"></i>审核
								</a>
								<form action="" method="post" id="hiddens">
									<div class="col-sm-2 col-padd">
										<span class="input-icon"> <input type="text"
											class="form-control input-sm borderrdu" name="name"
											value="${doctor.name }" placeholder="姓名/手机号"
											style="border-radius: 30px !important;"> <i
											class="glyphicon glyphicon-search blue" id="searchEr"></i>
										</span>
									</div>
								</form>
							</div>
							<table class="table table-striped table-hover table-bordered"
								id="bodyHtml">
								<thead>
									<tr role="row">
										<th width="5%"><label> <input type="checkbox"
												name="id" id="hvtck"> <span class="text"></span>
										</label></th>
										<th width="12%">医师编号 <span
											class="fa indicator fa-unsorted"></span>
										</th>
										<th width="12%">医师姓名 <span
											class="fa indicator fa-unsorted"></span>
										</th>
										<th width="12%">医师职称 <span
											class="fa indicator fa-unsorted"></span>
										</th>
										<th width="12%">手机号 <span
											class="fa indicator fa-unsorted"></span>
										</th>
										<th idth="12%">科室 <span class="fa indicator fa-unsorted"></span>
										</th>
										<th width="6%">状态 <span class="fa indicator fa-unsorted"></span>
										</th>
										<th width="15%">操作 <span class="fa indicator fa-unsorted"></span>
										</th>
									</tr>
								</thead>

								<tbody>
									<form action="" id="userform" method="post">
										<c:forEach items="${pager.list }" var="list">
											<tr>
												<td width="5%"><label> <input type="checkbox"
														name="id" value="${list.id }"> <span class="text"></span>
												</label></td>
												<td width="12%"><input type="text" class="six"
													value="${list.code }" disabled="disabled"></td>
												<td width="12%"><input type="text" class="six namese"
													value="${list.name }" disabled="disabled"></td>
												<td width="12%"><input type="text" class="six"
													value="${list.profession==1?'住院医师（助教）':list.profession==2?'主治医师（讲师）':list.profession==3?'副主任医师（副教授）':'主任医师（教授）' }"
													disabled="disabled"></td>
												<td width="12%"><input type="text"
													value="${list.mobile }" class="six" disabled="disabled">
												</td>
												<td width="12%"><input type="text" class="six"
													value="${list.department }" disabled="disabled"></td>
												<td width="6%"><c:if
														test="${list.status == 1 || list.status == 2 }">
														<span class="label label-success">已审核</span>
													</c:if> <c:if test="${list.status !=1 && list.status != 2 }">
														<span class="label label-default">未审核</span>
													</c:if></td>
												<td width="15%"><c:if test="${list.status ==1  }">
														<a href="#" class="btn btn-palegreen btn-xs gzsj" doctorId="${list.id }"><i
															class="fa fa-cog"></i>工作时间 </a>
															<input type="hidden" id="doctorId">
													</c:if> <a href="${ctx}/doctor/look?id=${list.id}&method=1"
													class="btn btn-ck btn-xs"><i
														class="fa fa-folder-open-o"></i> 查看</a> <a
													href="${ctx}/doctor/look?id=${list.id}&method=2"
													class="btn btn-info btn-xs"><i class="fa fa-pencil"></i>修改</a>
													<a href="#" onclick="deleteSingle(${list.id})"
													class="btn btn-danger btn-xs "><i class="fa fa-trash-o"></i>
														删除</a></td>
											</tr>
										</c:forEach>
									</form>
								</tbody>
							</table>

							<%@ include file="../def/common_pagebar.jsp"%>
							<%-- <div class="btn-font dw_page" currentPage="${pager.currentPage}"
								total="${pager.total}" totalPages="${pager.totalPages}"
								pageSize="${pager.pageSize}">
								<div class="zjtm">共${pager.totalPages }页${pager.total }条</div>
								<div class="zjrightb">
									<ul class="pagination pull-right">
										<c:if test="${pager.totalPages == 1 || pager.totalPages == 0}">
											<li class="footable-page-arrow disabled"><a
												data-page="prev" href="javascript:void(0)">上一页</a></li>
											<li class="footable-page active"><a data-page="0"
												href="#">1</a></li>
											<li class="footable-page-arrow disabled"><a
												data-page="next" href="javascript:void(0)">下一页</a></li>
										</c:if>
										<c:if test="${pager.totalPages != 1 && pager.totalPages != 0}">
											<c:if test="${pager.currentPage == 1}">
												<li class="footable-page-arrow disabled"><a
													data-page="prev" href="javascript:void(0)">上一页</a></li>
												<li class="footable-page active"><a data-page="0"
													href="#">1</a></li>
												<li class="footable-page"><a data-page="1"
													href="javascript:_go(2);">2</a></li>
												<li class="footable-page-arrow"><a data-page="next"
													href="javascript:_next();">下一页</a></li>
											</c:if>
											<c:if
												test="${pager.currentPage != 1 && pager.currentPage != pager.totalPages}">
												<li class="footable-page-arrow"><a data-page="prev"
													href="javascript:_back();">上一页</a></li>
												<li class="footable-page"><a
													data-page="${pager.currentPage-2}"
													href="javascript:_go('${pager.currentPage-1}');">${pager.currentPage-1}</a></li>
												<li class="footable-page active"><a
													data-page="${pager.currentPage-1}" href="#">${pager.currentPage}</a></li>
												<li class="footable-page"><a
													data-page="${pager.currentPage}"
													href="javascript:_go('${pager.currentPage+1}')">${pager.currentPage+1}</a></li>
												<li class="footable-page-arrow"><a data-page="next"
													href="javascript:_next();">下一页</a></li>
											</c:if>
											<c:if test="${ pager.currentPage == pager.totalPages}">
												<li class="footable-page-arrow"><a data-page="prev"
													href="javascript:_back();">上一页</a></li>
												<li class="footable-page"><a
													data-page="${pager.currentPage-2}"
													href="javascript:_go('${pager.currentPage-1}');">${pager.currentPage-1}</a></li>
												<li class="footable-page active"><a
													data-page="${pager.currentPage-1}" href="#">${pager.currentPage}</a></li>
												<li class="footable-page-arrow disabled"><a
													data-page="next" href="javascript:void(0)">下一页</a></li>
											</c:if>
										</c:if>
									</ul>
								</div>
							</div> --%>

						</div>
					</div>

				</div>

			</div>

		</div>

	</div>
	<!-- /右侧内容 -->

	<div>
		<P class="bottomfont">© 2016 Angel Health Management Ltd. :
			天使健康管理有限公司</P>
	</div>
	<div class="modal fade bs-example-modal-lg in" tabindex="-1"
		role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="false"
		style="display: none;">
		<div class="modal-dialog modal-lg">
			<div class="modal-content">
				<div class="calendar" id="calendarDiv" style="display: block;">
					<div class="header">
						<a href="#" data-rel="back" class="back-btn"></a> 日历 <a
							href="javascript:void();" class="today">今天</a> 
							<button type="button" class="close" style="margin-right: 10px;margin-top: 3px" data-dismiss="modal" aria-hidden="true">×</button>
					</div>
					<div data-role="content" class="date-cont">
						<div class="date-main">
							<div class="date-title">
								<a href="#" class="pre-date"><i id="left-btn" style="margin-top: 2px"
									class="fa fa-angle-left cal_mons_l mt10 cal_mons_turn"></i></a>
								<span class="center-date"><span></span>年<span></span>月</span> <a
									href="#" class="next-date"><i id="right-btn" style="margin-top: 2px"
									class="fa fa-angle-right cal_mons_r mt10 cal_mons_turn"></i></a>
							</div>
							<div id="calendar"></div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>

</html>
<script>
    $(function () {
        //编辑
        function editClass(_this){
            if($(_this).html() == "编辑"){
                $(_this).parent().parent().find(".time-input").hide();
                $(_this).parent().parent().find(".time-select").show();
                $(_this).html("完成");
                $(_this).parent().parent().find("input").removeAttr("disabled");
            }else {
                $(_this).parent().parent().find(".time-input").show();
                $(_this).parent().parent().find(".time-select").hide();
                $(_this).html("编辑");
                $(_this).parent().parent().find("input").attr("disabled",true);
            }
        }
        // 删除
        function removeClass(_this){
            $(_this).parent().parent().remove();
        }

        $(".editClass").on('click',function(){
            editClass(this)
        });

        $(".removeClass").on('click',function(){
            removeClass(this)
        });

      //查询
		$("#searchEr").on('click', function() {
			$("#hiddens").submit();
		});

       
    });
    
	function check(){
		var ids = $("#userform").serialize();
		console.info(ids);
		if(!ids){
			toastr.warning("请选择要审核的医师");
			return false;
		}
		id = ids.replace(/id=/g,"");
		if(id.indexOf("&") > 0){
			toastr.warning("一次只能选择一个医师进行审核");
			$('input[name=id]').removeAttr("checked");
			return false;
		}
		$.ajax({
			url : "${ctx}/doctor/findDoctorById",
			type : "POST",
			data : {'id':id},
			dataType : "json",
			success : function(data) {
				console.info(data.status)
				if(data.status == 1 || data.status == 2){
					toastr.warning("医师已审核");
					$('input[name=id]').removeAttr("checked");
				}else{
					location.href = "${ctx}/doctor/checkDoctor?id="+id;
				}
			}
		});
	}

	$("#hvtck").click(function(){
		var eles = document.getElementsByName("id");
		for (var i = 1; i < eles.length; i++) {
			eles[i].checked = eles[0].checked;
		}
	})
	$("#deleteBatch").click(function(){
		var ids = $("#userform").serialize();
		if(!ids){
			toastr.warning("请选择要删除的内容");
			return false;
		}
		ids = ids.replace(/id=/g,"");
		if(confirm("是否确定删除")){
			$.ajax({
				url : "${ctx}/doctor/delete",
				type : "POST",
				data : {"ids":ids},
				dataType : "json",
				success : function(data) {
					if (data > 0) {
						window.location.href = "${ctx}/doctor/index";
						location.reload();
					} else {
						toastr.error("删除失败！");
						return false;
					}
				}
			});
		}
	})
	function deleteSingle(id){
		if(confirm("是否确定删除")){
			$.ajax({
				url : "${ctx}/doctor/deleteById",
				type : "POST",
				data : {"id":id},
				dataType : "json",
				success : function(data) {
					if (data > 0) {
						window.location.href = "${ctx}/doctor/index";
					} else {
						toastr.error("删除失败！");
						return false;
					}
				}
			});
		}
	}
</script>